<?php
class Index extends BaseController {
    
    function __construct() {
        parent::__construct();
    }
    
    //登录接口
    function login(){
        $data = Input::post('data');
        $sql_data = json_decode($data,true);
        $sql_data['pass_word'] = md5($sql_data['pass_word']);
        $company = new MCompany();
        $sql_result = $company->selectAdmin($sql_data);
        if($sql_result && $sql_result['status'] == 1){
            unset($sql_result['pass_word']);
            $this->_cookie->set('user',json_encode($sql_result));
            $this->jsonMsg(200, "请求成功");
        }  else {
            $this->jsonMsg(100, "用户名或密码不正确");
        }
    }
    
    //退出接口
    function logout(){
        $this->cookie = '';
        $this->_cookie->del('user');
        $this->jsonMsg(200, "退出");
    }
          
    //登录页面
    function index(){
        if (!empty($this->cookie)) {
            header('location:?m=index-Order&do=add');
            exit;
        } else {
            $template_path = __TPL_PATH__ . 'Index/index.html';
            $this->_view->display($template_path, $this->assign);
        }
    }

}

